package com.purchase.ml.service.calendar.impl;

import com.purchase.ml.entity.calendar.SysCalendar;
import com.purchase.ml.mapper.calendar.SysCalendarMapper;
import com.purchase.ml.service.calendar.SysCalendarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
* <p>
    *  服务实现类
    * </p>
*
* @author kyyang
* Created 2021-05-18
*/
@Service
@Slf4j
public class SysCalendarServiceImpl extends ServiceImpl<SysCalendarMapper, SysCalendar> implements SysCalendarService {

    @Autowired
    private  SysCalendarMapper  sysCalendarMapper;


    @Override
    public void generateCalender() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        for(int i= 0; i<2000;i++){
            calendar.setTime(sdf.parse("2021-04-01"));
            calendar.add(Calendar.DATE,i);
            SysCalendar sysCalendar = new SysCalendar();
            sysCalendar.setCreatedAt(calendar.getTime());
            sysCalendarMapper.insert(sysCalendar);
        }
    }
}
